
import java.sql.*;

public class Demo08 {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        try {
            DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
            String url = "jdbc:mysql://localhost:3306/demo?serverTimezone=GMT&useSSL=false&characterEncoding=utf-8";
            String user = "root";
            String password = "1015";
            connection = DriverManager.getConnection(url, user, password);
            statement = connection.createStatement();
            String sql = "delete from tb_user where id=1";
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try{
                if(connection !=null){
                    connection.close();
                }
            }catch (SQLException e){
                throw new RuntimeException(e);
            }
        }
    }
}
    


